<template>
  <div>
    <div class="werapp">
      <h1>用户管理</h1>
    </div>
    <el-table :data="list" border style="width: 100%">
      <el-table-column prop="id" label="编号" width="180"> </el-table-column>
      <el-table-column prop="username" label="用户名" width="180">
      </el-table-column>
      <el-table-column prop="email" label="邮箱"> </el-table-column>
      <el-table-column prop="phone" label="电话"> </el-table-column>
      <el-table-column prop="createTime" label="注册时间">
        <template slot-scope="scope">
          {{ new Date(scope.row.createTime).format() }}
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pagenum"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
import  {user}  from "../../api/index";
export default {
  data() {
    return {
      list: [],
      total: 0,
      pagesize: 5,
      pagenum: 1,
    };
  },
  methods: {
    getdata() {
      user({ pageSize: this.pagesize, pageNum: this.pagenum }).then((res) => {
        console.log(res.data.data);
        this.list = res.data.list;
        this.total = res.data.total;
      });
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pagesize = val;
      this.getdata();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pagenum = val;
      this.getdata();
    },

  },
  created() {
    this.getdata();
  },
};
</script>

<style lang="scss" scoped>
.werapp {
  h1 {
    font-size: 50px;
    padding-left: 15px;
    padding-top: 20px;
  }
}
</style>